package com.web.music.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.*;

// TODO [done]
// You have to make this class a persistent entity
@Entity
public abstract class Artist implements PersistentEntity {

	@Id 
	@Column(name="ARTIST_ID", nullable = false) 
	private Long id;
	
	@ManyToMany
	@JoinTable(
	    	name="ARTIST_GENRE",
		joinColumns=@JoinColumn(
	  		name="ARTIST_ID",referencedColumnName="ARTIST_ID"),
		inverseJoinColumns=@JoinColumn(
			name="GENRE_ID", referencedColumnName="GENRE_ID"))
			
	private List<Genre> genres = new ArrayList<Genre>();
	
	@OneToMany(cascade=CascadeType.ALL, mappedBy="artist")
	private List<Album> albums = new ArrayList<Album>();;

	public List<Genre> getGenres() {
		return genres;
	}

	public void setGenres(List<Genre> genres) {
		this.genres = genres;
	}

	public List<Album> getAlbums() {
		return albums;
	}

	public void setAlbums(List<Album> albums) {
		this.albums = albums;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	public void addAlbum(Album album){
		this.albums.add(album);
	}
}
